package com.example.library_common.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

public abstract class BaseLazyDataBindingFragment<T extends ViewDataBinding> extends LazyFragment {

    protected T viewBinder;

    @Override
    public final Object getLayoutId() {
        return getLayoutId();
    }

    public abstract @LayoutRes
    int layoutId();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        int mLayoutId = layoutId();
        viewBinder = DataBindingUtil.inflate(getLayoutInflater(), mLayoutId, container, false);
        return viewBinder.getRoot();
    }
}
